package com.petcare;

import java.util.ArrayList;
import com.bd.PetsModule;
import com.bd.AlarmsModule;
import com.bd.Utilities;

import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.Toast;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.view.View.OnClickListener;


public class alarmdetail extends Activity {
	
	AlarmsModule myAlarm = null;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alarmdetail);
        
        try{
        Bundle bundle = this.getIntent().getExtras();
	    myAlarm = Utilities.datasource.getAlarm(bundle.getInt("pk")+"");
	    System.out.println(myAlarm);
	    }
        catch(Exception e){
        	System.out.println("Exception: " +e);
        }
        
	   
	    TextView textName = (TextView) findViewById(R.id.TextView01);
	    textName.setText(myAlarm.getActivity());
	    
	    TextView textPet = (TextView) findViewById(R.id.TextView04);
	    PetsModule myPet = Utilities.datasource.getPet(myAlarm.getPetid());
	    textPet.setText(myPet.getName());
	    
	    TextView textDays = (TextView) findViewById(R.id.TextView05);
	    textDays.setText(myAlarm.getDays());
	    
	    TextView textHours= (TextView) findViewById(R.id.TextView07);
	    String hora = String.valueOf(myAlarm.getHour()) + " : " + String.valueOf(myAlarm.getMinute()) + " "+ String.valueOf(myAlarm.getAmpm());
	    textHours.setText(hora);
	    
	    final Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener() {
            
        	public void onClick(View v) {
        	
            		Bundle bundle = new Bundle();
            		bundle.putInt("pk", myAlarm.getPk());
    				Intent myIntent = new Intent(alarmdetail.this, setalarm.class);
    				myIntent.putExtras(bundle);
                	startActivity(myIntent);
                }
            
        });
	    
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
